package com.epoque.gate.server.utils;

import javax.servlet.http.HttpServletRequest;

/**
 * 
 * @ClassName: ClientUtil
 * @Description: 客户端工具类
 * @author qiuxianfeng
 * @date 2018年8月29日
 *
 */
public class ClientUtil {
	
    /**
     * 
     * @Title: getClientIp
     * @author qiuxianfeng
     * @Description: 获取客户端真实ip
     * @param @param request
     * @param @return    参数
     * @return String    返回类型
     * @throws
     */
	public static String getClientIp(HttpServletRequest request){
		String ip = request.getHeader("x-forwarded-for");
		if (ip==null||ip.length()==0||"unknown".equalsIgnoreCase(ip))
			ip = request.getHeader("Proxy-Client-IP");
		if (ip==null||ip.length()==0||"unknown".equalsIgnoreCase(ip))
			ip = request.getHeader("WL-Proxy-Client-IP");
		if (ip==null||ip.length()==0||"unknown".equalsIgnoreCase(ip))
			ip = request.getRemoteAddr();
		return ip;
	}
}
